package com.pyb.common.datasource.enums;

import com.google.common.base.Strings;

import org.apache.commons.lang3.StringUtils;

public enum DataSourceEnum {

    INSURE("insure")

    ;

    private static final String DATASOURCE_PREFIX = "DataSource";

    private String text;

    DataSourceEnum(String text) {
        this.text = StringUtils.join(text, DATASOURCE_PREFIX);
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public static DataSourceEnum match(String text) {
        if (Strings.isNullOrEmpty(text)) {
            return null;
        }
        for (DataSourceEnum dataSourceEnum : DataSourceEnum.values()) {
            if (StringUtils.equals(text + DATASOURCE_PREFIX, dataSourceEnum.getText())) {
                return dataSourceEnum;
            }
        }
        return null;
    }
}
